<Select DataSource="@_persons" 
        @bind-Value="@_selectedValue"
        LabelName="@nameof(Person.Name)" 
        ValueName="@nameof(Person.Id)" 
        DisabledName="@nameof(Person.NotAvailable)"
        DefaultValue="12"
        Placeholder="Select a person"
        OnSelectedItemChanged="OnSelectedItemChangedHandler"
        OnDataSourceChanged="OnDataSourceChangedHandler"
        SortByLabel="@SortDirection.Ascending"
        AllowClear
        Style="width: calc(100% - 68px);">
</Select>
<Dropdown Style="padding-left: 8px;" Trigger="@(new TriggerType[] { TriggerType.Click })">
    <Overlay>
        <Menu Selectable="false">
            <MenuItem OnClick="@SetDatasource1">Set Datasource 1</MenuItem>
            <MenuItem OnClick="@SetDatasource2">Set Datasource 2</MenuItem>
            <MenuItem OnClick="@SetDatasourceNull">Set Datasource to NULL</MenuItem>
            <MenuItem OnClick="@AddPerson">Add Person (John)</MenuItem>
            <MenuItem OnClick="@RemovePerson">Remove Person (John)</MenuItem>
            <MenuItem OnClick="@ClearDS">Clear Datasource</MenuItem>
        </Menu>
    </Overlay>
    <ChildContent>
        <a class="ant-dropdown-link" @onclick:preventDefault>Actions<Icon Type="down" /></a>        
    </ChildContent>
</Dropdown>
<br /><br />
<p>
    Selected Value: @_selectedValue <br/>
    Selected Item: @_selectedItem?.Name
</p>
@code
{
    class Person
    {
        public Person(){}

        public Person(Person obj)
        {
            Id = obj.Id;
            Name = obj.Name;
            NotAvailable = obj.NotAvailable;
        }

        public int Id { get; set; }
        public string Name { get; set; }
        public bool NotAvailable { get; set; }
    }

    List<Person> _persons;
    List<Person> _persons1;
    List<Person> _persons2;

    int? _selectedValue;
    Person _selectedItem;

    protected override void OnInitialized()
    {
        _persons1 = new List<Person>
        {
            new Person {Id = 1, Name = "Jack"}, 
            new Person {Id = 2, Name = "Lucy"}, 
            new Person {Id = 3, Name = "Yaoming"}, 
            new Person {Id = 4, Name = "Frieda"}, 
            new Person {Id = 5, Name = "Kathy", NotAvailable = true}, 
            new Person {Id = 6, Name = "Kate"}, 
            new Person {Id = 7, Name = "Eric"}
        };

        _persons2 = new List<Person> 
        {
            new Person {Id = 8, Name = "Jake", NotAvailable = true}, 
            new Person {Id = 9, Name = "Olaf"},
            new Person {Id = 10, Name = "Sven"}, 
            new Person {Id = 11, Name = "Bernd", NotAvailable = true}, 
            new Person {Id = 12, Name = "Jane"}, 
            new Person {Id = 13, Name = "John"}};
    }

    private void SetDatasource1()
    {
        _persons = _persons1.ConvertAll(x => new Person(x));
    }

    private void SetDatasource2()
    {
        _persons = _persons2.ConvertAll(x => new Person(x));
    }

    private void SetDatasourceNull()
    {
        _persons = null;
    }

    private void ClearDS()
    {
        _persons?.Clear();
    }

    private void AddPerson()
    {
        if (_persons != null && _persons.All(x => x.Id != 13))
            _persons.Add(new Person() {Id = 13, Name = "John"});
    }

    private void RemovePerson()
    {
        var item = _persons?.FirstOrDefault(x => x.Id == 13);

        if (item != null)
            _persons.Remove(item);
    }

    private void OnSelectedItemChangedHandler(Person value)
    {
        _selectedItem = value;
    }

    private void OnDataSourceChangedHandler()
    {
        Console.WriteLine("--- DataSourceChanged --- " + DateTime.Now.ToString("O"));
    }
}
